package com.gopher.gopherbeasts;

import java.util.ArrayList;
import java.util.List;

public class Controls {

	private List<Control> all = new ArrayList<Control>();

	public final class Control {

		public boolean wasDown = false;
		public boolean isDown = false;
		public boolean nextState = false;

		public Control() {
			all.add(this);
		}

		public void update() {
			wasDown = isDown;
			isDown = nextState;
		}

		public boolean justPressed() {
			return !wasDown && isDown;
		}

		public boolean justReleased() {
			return wasDown && !isDown;
		}
	}

	public Control jump = new Control();
	public Control left = new Control();
	public Control right = new Control();
	public Control action = new Control();

	public void update() {
		for (Control c : all) {
			c.update();
		}
	}

}
